import { BasicColumn, FormSchema } from '/@/components/Table';
import { getToken } from '/@/utils/auth';
import { render } from '/@/utils/common/renderUtils';
import moment from 'moment-timezone';

export const columns: BasicColumn[] = [
  {
    title: 'token',
    dataIndex: 'tokenValue',
    width: 180,
  },
  {
    title: '到期时间',
    dataIndex: 'expiration',
    width: 180,
    customRender: ({ text, record }) => {
      const dateString = moment(text).format('YYYY-MM-DD HH:mm:ss');
      return dateString;
    },
  },
  {
    title: '用户账号',
    dataIndex: 'username',
    width: 180,
    customRender: ({ text, record }) => {
      const token = getToken();
      if (record.token === token) {
        return text + '（我）';
      }
      return text;
    },
  },
  {
    title: '授权类型',
    dataIndex: 'grantType',
    width: 180,
  },
  {
    title: '所属应用',
    dataIndex: 'clientId',
    width: 180,
  },
  {
    title: '账号类型',
    dataIndex: 'accountType',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'username',
    label: '用户姓名',
    component: 'Input',
    colProps: { span: 8 },
  },
];
